712 research outputs found

    System FC, as implemented in GHC

    Get PDF

    An Overabundance of Equality: Implementing Kind Equalities into Haskell

    Get PDF
    Haskell, as embodied by version 7.10.1 of the Glasgow Haskell Compiler (GHC), supports reasoning about equality among types, via generalized algebraic datatypes (GADTs) and type families. However, these features are not available among the kinds that clas- sify the types. Motivated by a concrete example of how kind equali- ties can help programmers today, this paper presents the challenges and solutions encountered in integrating kind equalities into GHC, an industrial-strength compiler. The challenges addressed here all surround the many notions of type equality that exist in GHC to- day, and in particular around GHC’s role mechanism. These many different relations on types complicate the theory considerably An update of GHC supporting reasoning about kind equalities is a key part of this work

    System FC, as implemented in GHC

    Get PDF

    An Overabundance of Equality: Implementing Kind Equalities into Haskell

    Get PDF
    Haskell, as embodied by version 7.10.1 of the Glasgow Haskell Compiler (GHC), supports reasoning about equality among types, via generalized algebraic datatypes (GADTs) and type families. However, these features are not available among the kinds that clas- sify the types. Motivated by a concrete example of how kind equali- ties can help programmers today, this paper presents the challenges and solutions encountered in integrating kind equalities into GHC, an industrial-strength compiler. The challenges addressed here all surround the many notions of type equality that exist in GHC to- day, and in particular around GHC’s role mechanism. These many different relations on types complicate the theory considerably An update of GHC supporting reasoning about kind equalities is a key part of this work

    Promoting Functions to Type Families in Haskell (extended version)

    Get PDF
    Haskell, as implemented in the Glasgow Haskell Compiler (GHC), is enriched with many extensions that support type-level programming, such as promoted datatypes, kind polymorphism, and type families. Yet, the expressiveness of the type-level language remains limited. It is missing many features present at the term level, including case expressions, anonymous functions, partially-applied functions, and let expressions. In this paper, we present an algorithm – with a proof of correctness – to encode these term-level constructs at the type level. Our approach is automated and capable of promoting a wide array of functions to type families.We also highlight and discuss those term-level features that are not promotable. In so doing, we offer a critique on GHC’s existing type system, showing what it is already capable of and where it may want improvement. We believe that delineating the mismatch between GHC’s term level and its type level is a key step toward supporting dependently typed programming. We have implemented our approach as part of the singletons package, available online

    Promoting Functions to Type Families in Haskell (extended version)

    Get PDF
    Haskell, as implemented in the Glasgow Haskell Compiler (GHC), is enriched with many extensions that support type-level programming, such as promoted datatypes, kind polymorphism, and type families. Yet, the expressiveness of the type-level language remains limited. It is missing many features present at the term level, including case expressions, anonymous functions, partially-applied functions, and let expressions. In this paper, we present an algorithm – with a proof of correctness – to encode these term-level constructs at the type level. Our approach is automated and capable of promoting a wide array of functions to type families.We also highlight and discuss those term-level features that are not promotable. In so doing, we offer a critique on GHC’s existing type system, showing what it is already capable of and where it may want improvement. We believe that delineating the mismatch between GHC’s term level and its type level is a key step toward supporting dependently typed programming. We have implemented our approach as part of the singletons package, available online

    The Thoralf Plugin: For Your Fancy Type Needs

    Get PDF
    Many fancy types (e.g., generalized algebraic data types, type families) require a type checker plugin. These fancy types have a type index (e.g., type level natural numbers) with an equality relation that is difficult or impossible to represent using GHC’s built-in type equality. The most practical way to represent these equality relations is through a plugin that asserts equality constraints. However, such plugins are difficult to write and reason about. In this paper, we (1) present a formal theory of reasoning about the correctness of type checker plugins for type indices, and, (2) apply this theory in creating Thoralf, a generic and extensible plugin for type indices that translates GHC constraint problems to queries to an external SMT solver. By “generic and extensible”, we mean the restrictions on extending Thoralf are slight, and, if some type index could be encoded as an SMT sort, then a programmer could extend Thoralf by providing this encoding function

    Constrained Type Families

    Get PDF
    We present an approach to support partiality in type-level computation without compromising expressiveness or type safety. Existing frameworks for type-level computation either require totality or implicitly assume it. For example, type families in Haskell provide a powerful, modular means of defining type-level computation. However, their current design implicitly assumes that type families are total, introducing nonsensical types and significantly complicating the metatheory of type families and their extensions. We propose an alternative design, using qualified types to pair type-level computations with predicates that capture their domains. Our approach naturally captures the intuitive partiality of type families, simplifying their metatheory. As evidence, we present the first complete proof of consistency for a language with closed type families.Comment: Originally presented at ICFP 2017; extended editio

    Levity Polymorphism

    Get PDF
    Parametric polymorphism is one of the linchpins of modern typed programming, but it comes with a real performance penalty. We describe this penalty; offer a principled way to reason about it (kinds as calling conventions); and propose levity polymorphism. This new form of polymorphism allows abstractions over calling conventions; we detail and verify restrictions that are necessary in order to compile levity-polymorphic functions. Levity polymorphism has created new opportunities in Haskell, including the ability to generalize nearly half of the type classes in GHC\u27s standard library
    • 

    corecore